﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    >

    <ControlTemplate x:Key="RedUnderlineError" >
            <StackPanel>
                <Rectangle Height="7" Margin="0,-5,0,0">
                    <Rectangle.Fill>
                        <DrawingBrush TileMode="Tile"
                                      ViewportUnits="Absolute"
                                      Viewport="0 0 4 7"
                                      ViewboxUnits="Absolute"
                                      Viewbox="0 0 4 7">
                            <DrawingBrush.Drawing>
                                <GeometryDrawing>
                                    <GeometryDrawing.Pen>
                                        <Pen Brush="Red"
                                             Thickness="0.75" />
                                    </GeometryDrawing.Pen>
                                    <GeometryDrawing.Geometry>
                                        <PathGeometry Figures="M0,2 L2,5 4,2, 6,5" />
                                    </GeometryDrawing.Geometry>
                                </GeometryDrawing>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </StackPanel>
        </ControlTemplate>

    <ControlTemplate x:Key="ValidationErrorTemplate">
        <DockPanel>
            <Grid DockPanel.Dock="Left"
                  Width="16"
                  Height="16"
                  VerticalAlignment="Center"
                  Margin="0 0 3 0">
                <Ellipse Width="16"
                         Height="16"
                         Fill="Red" />

                <Ellipse Width="3"
                         Height="8"
                         VerticalAlignment="Top"
                         HorizontalAlignment="Center"
                         Margin="0 2 0 0"
                         Fill="White" />
                <Ellipse Width="2"
                         Height="2"
                         VerticalAlignment="Bottom"
                         HorizontalAlignment="Center"
                         Margin="0 0 0 2"
                         Fill="White" />
            </Grid>
            <Border BorderBrush="Red"
                    BorderThickness="2"
                    CornerRadius="2">
                <AdornedElementPlaceholder />
            </Border>
        </DockPanel>
    </ControlTemplate>

    <Style TargetType="{x:Type ComboBox}"
           BasedOn="{StaticResource {x:Type ComboBox}}">

        <Setter Property="Validation.ErrorTemplate"
                Value="{StaticResource ValidationErrorTemplate}" />
    </Style>

    <Style TargetType="{x:Type TextBox}"
           BasedOn="{StaticResource {x:Type TextBox}}">

        <Setter Property="Validation.ErrorTemplate"
                Value="{StaticResource ValidationErrorTemplate}" />
    </Style>

    <Style TargetType="{x:Type CheckBox}"
           BasedOn="{StaticResource {x:Type CheckBox}}">

        <Setter Property="Validation.ErrorTemplate"
                Value="{StaticResource ValidationErrorTemplate}" />
    </Style>

    <Style TargetType="{x:Type ListBox}"
           BasedOn="{StaticResource {x:Type ListBox}}">

        <Setter Property="Validation.ErrorTemplate"
                Value="{StaticResource ValidationErrorTemplate}" />
    </Style>
</ResourceDictionary>